package com.grupoconstruobras.sigo.general.data;

import com.grupoconstruobras.sigo.data.IEntityTipoString;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * The persistent class for the m_pais database table.
 */
@Entity
@Immutable
@Table(name = "pais", schema = "public")
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Pais implements Serializable, IEntityTipoString {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1010796902504404493L;

	@Id
	@NotNull
	@NotEmpty
	// @Column(name = "id_pais")
	@Column(name = "idpais")
	private Integer idPais;

	@Transient
	private String activo;

	@Column(name = "pais")
	private String nombre;

	// bi-directional many-to-one association to Departamento
	@OneToMany(mappedBy = "MPai", fetch = FetchType.LAZY)
	private List<Departamento> MDepartamentos;

	@OneToMany(mappedBy = "MPais", fetch = FetchType.LAZY)
	private List<Municipio> MMunicipios;

	public Pais() {
	}

	public Integer getIdPais() {
		return this.idPais;
	}

	public void setIdPais(Integer idPais) {
		this.idPais = idPais;
	}

	
	public String getActivo() {
		// return this.activo;
		return "1";
	}

	
	public void setActivo(String activo) {
		// this.activo = activo;
	}

	public String getNombre() {
		return this.nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public List<Departamento> getMDepartamentos() {
		return this.MDepartamentos;
	}

	public void setMDepartamentos(List<Departamento> MDepartamentos) {
		this.MDepartamentos = MDepartamentos;
	}

	public List<Municipio> getMMunicipios() {
		return MMunicipios;
	}

	public void setMMunicipios(List<Municipio> mMunicipios) {
		MMunicipios = mMunicipios;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (other == null || !(other instanceof Pais))
			return false;

		if (getIdPais() != null)
			return getIdPais().equals(((Pais) other).getIdPais());
		return super.equals(other);
	}

	@Override
	public int hashCode() {
		if (getIdPais() == null)
			return super.hashCode();
		else
			return getIdPais().hashCode();
	}

	public String getId() {
		return ""+this.getIdPais();
	}

}
